
import java.io.*;
import java.net.*;
import java.security.*;


public class callback_server {
	
	private static int port=4444, maxConnections=0;
	public static void main(String[] args) {
		int i=0;
		
		try{
			ServerSocket listener = new ServerSocket(port);
			Socket server;
			
			while((i++ < maxConnections) || (maxConnections == 0)){
				doComms connection;
				
				server = listener.accept();
				doComms conn_c= new doComms(server);
				Thread t = new Thread(conn_c);
				t.start();
			}
		} catch (IOException ioe) {
			System.out.println("IOException on socket listen: " + ioe);
			ioe.printStackTrace();
		}
	}
	
}

class doComms implements Runnable {
    private Socket server;
    private String line,input;
	
    doComms(Socket server) {
		this.server=server;
    }
	
    public void run () {
		
		input="";
		
		try {
			DataInputStream in = new DataInputStream (server.getInputStream());
			input = in.readLine();
			server.close(); // Immediately close the connection to the client so that it doesn't block
			
			
			
			
		} catch (IOException ioe) {
			System.out.println("IOException on socket listen: " + ioe);
			ioe.printStackTrace();
		}
    }
}
